$(function() {
    var eventContent =
        "<div class='skuiwu-danger danger' id='senseDemo'>" +
        "<div class='header'><h3>危险管控&nbsp;&nbsp;&nbsp;1009</h3></div>" +
        "<div id='myScrollspy' class='skuiwu-navbar navbar navbar-default navbar-static' role='navigation'><div class='content'>" +
        "<div class='message'><h2>检修井盖破损</h2><h4>3次巡检记录</h4></div>" +
        "<div class='details'><h6>地址：</h6><p>湖里区仙岳路辅路管理所附</p></div>" + 
        "<div class='details'><h6>内容：</h6><p>湖边补调管道破损</p></div>" +
        "<div class='classify'>" +
        "<div><h6>坐标：</h6><p class='coordinate'>北纬N24.23.55.55 东经E118.56 2152</p></div><h6>事件编号：</h6><p>1009</p></div>" +
        "</div></div>" +
        "<div data-spy='scroll' data-target='#myScrollspy' data-offset='0' class='skuiwu-scroll'><div class='footer'>" +
        "<div class='danger-details'>"+
        "<div class='user-message'><img src='./images/people.png'><div><h1>王冰冰</h1><h5>湖边水库管理所</h5></div></div>" +
        "<div class='details'><h6>时间：</h6><p>017-01-11 09:30</p></div>" +
        "<div class='details'><h6>主题：</h6><p>湖里区仙岳路辅路管理所附</p></div>" +
        "<div class='details-images'><h6>图片：</h6><div class='images'>" +
        "<img src='./images/people.png'><img src='./images/people.png' ><img src='./images/people.png'><img src='./images/people.png'></div></div>"+
        "</div>"+
        "<div class='danger-details'>"+
        "<div class='user-message'><img src='./images/people.png'><div><h1>王冰冰</h1><h5>湖边水库管理所</h5></div></div>" +
        "<div class='details'><h6>时间：</h6><p>017-01-11 09:30</p></div>" +
        "<div class='details'><h6>主题：</h6><p>湖里区仙岳路辅路管理所附</p></div>" +
        "<div class='details-images'><h6>图片：</h6><div class='images'>" +
        "<img src='./images/people.png'><img src='./images/people.png' ><img src='./images/people.png'><img src='./images/people.png'></div></div>"+
        "</div>"+
        "</div></div>"+
        "</div>";
    var map = new BMap.Map("map"); // 百度地图API定位一个厦门大位置功能
    var point = new BMap.Point(118.10388605, 24.48923061);
    var eventWindow = new BMap.InfoWindow(eventContent); // 创建信息窗口对象
    map.centerAndZoom(point, 15);
    map.enableScrollWheelZoom();
    //创建传感小图标
    var pt = new BMap.Point(118.10388605, 24.5);
    var myIcon = new BMap.Icon("images/sense.png", new BMap.Size(300, 157));
    var marker = new BMap.Marker(pt, { icon: myIcon }); // 创建标注
    map.addOverlay(marker);
    marker.addEventListener("click", function() {
        this.openInfoWindow(eventWindow);
        //图片加载完毕重绘infowindow
        document.getElementById('senseDemo').onload = function() {
            eventWindow.redraw(); //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
        }
    });
     removeSection = function(e) {
                $(e).parents(".section").remove();
                $('[data-spy="scroll"]').each(function() {
                    var $spy = $(this).scrollspy('refresh')
                });
            }


})
